home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_VID / BUTTHD.ZIP;1 / BEAVIS.PAS next >
Encoding:
Pascal/Delphi Source File  |  1993-10-06  |  2.4 KB  |  104 lines

  1. program ScreenSaver;
  2.  
  3. uses Wintypes, WinProcs, Objects, OMemory, OWindows, ODialogs, Saver;
  4.  
  5. {The below description must start with the {$D SCRNSAVE  and
  6. follow with the name to show up in control panel.  You must
  7. compile this program to an .EXE and copy it to your windows
  8. directory with the extention .SCR. }
  9.  
  10. {$D SCRNSAVE Beavis & ButtHead}
  11.  
  12. {$R BEAVIS.RES}
  13.  
  14. const
  15. NumberOfBitmaps = 2;
  16.  
  17. type
  18.  
  19. TSaveApplication = object(TSApplication)
  20.   procedure InitMainWindow; virtual;
  21.   destructor Done; virtual;
  22.  end;
  23.  
  24. PSaveWindow = ^TSaveWindow;
  25. TSaveWindow = object(TScrnSavWindow)
  26.   hBmp : array[1..NumberofBitmaps] of  hBitmap;
  27.   constructor Init(aParent: PWindowsObject; aTitle: PChar);
  28.   procedure SetupWindow; virtual;
  29.   procedure Animate; virtual;
  30.   destructor Done; virtual;
  31. end;
  32.  
  33. procedure TSaveApplication.InitMainWindow;
  34. begin
  35.  if (ParamStr(1) <> '/c') and (ParamStr(1) <> '-c') then
  36.    MainWindow:= New(PSaveWindow, Init(nil, 'ScreenSaver'))
  37.  else
  38.  begin
  39.    Configure := True;
  40.    MainWindow := New(PDialog, Init(nil, 'ConfigDialog'));
  41.  end
  42. end;
  43.  
  44. constructor TSaveWindow.Init(aParent: PWindowsObject; aTitle: PChar);
  45. begin
  46.   BackGroundColor := Null_Brush;
  47.   TScrnSavWindow.Init(aParent, aTitle);
  48. end;
  49.  
  50. procedure TSaveWindow.SetupWindow;
  51. begin
  52.   Randomize;
  53.   TScrnSavWindow.SetupWindow;
  54.   hBmp[1] := loadBitmap(hInstance, 'Beavis');
  55.   hBmp[2] := loadBitmap(hInstance, 'Butthead');
  56. end;
  57.  
  58. procedure TSaveWindow.Animate;
  59. var
  60.   MyHdc, MemhDC: hDC;
  61.   BitMp : TBitMap;
  62.   Rect:TRect;
  63.   bmNumber: Byte;
  64.   x,y:Word;
  65. begin
  66.   bmNumber := Random(2) + 1;
  67.   MyHDC := GetWindowDC(hWindow);
  68.   MemHDC := CreateCompatibleDC(myHDC);
  69.   GetClientRect(hWindow,Rect);
  70.   SelectObject(MemHDC, hBmp[bmNumber]);
  71.   GetObject(hbmp[bmNumber], sizeof(BitMp), @BitMp);
  72.   x := random(Rect.Right - BitMp.bmWidth);
  73.   y := random(Rect.Bottom - BitMp.bmHeight);
  74.   StretchBlt(MyHdc, x, y, Bitmp.bmWidth,
  75.              Bitmp.bmHeight , memHDC, 0, 0,
  76.              Bitmp.bmWidth, bitmp.bmHeight, SRCcopy);
  77.   ReleaseDC(hWindow, MyHDC);
  78.   DeleteDC(MemHDC);
  79.   ReleaseDC(hWindow, MyHDC);
  80. end;
  81.  
  82. destructor TSaveWindow.Done;
  83. var
  84.   i: Integer;
  85. begin
  86.   for i := 1 to NumberOfBitmaps do
  87.     Deleteobject(hBmp[i]);
  88.   TScrnSavWindow.Done;
  89. end;
  90.  
  91. destructor TSaveApplication.Done;
  92. begin
  93.   TApplication.Done;
  94. end;
  95.  
  96. var
  97.   TSApp: TSaveApplication;
  98.  
  99. begin
  100.   TSApp.Init('Saver');
  101.   TSApp.Run;
  102.   TSApp.Done;
  103. end.
  104.